<?php

/**
 * Created by PhpStorm.
 * User: raymon
 * Date: 17-8-11
 * Time: 上午9:59
 */
class MY_Model extends CI_Model
{
    public function __construct()
    {
        $this->load->database();

    }

    public function get_all($table)
    {
        $this->db->from($table);
        $query = $this->db->get();
        return $query->result_array();
    }

    public function get($table, $id)
    {
        $this->db->from($table);
        $this->db->where('id', $id);
        $query = $this->db->get();
        return $query->row_array();
    }

    public function add($table, $data)
    {
        return $this->db->insert($table, $data);
    }

    public function update($table, $id, $data)
    {
        $this->db->where('id', $id);
        $this->db->update($table, $data);
        return true;
    }

    public function del($table, $id)
    {
        $this->db->where('id', $id);
        return $this->db->delete($table);
    }
}